//
//  BZ_ComenLoadAnimation.m
//  penzer
//
//  Created by caiyc on 2018/11/26.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "BZ_ComenLoadAnimation.h"
@interface BZ_ComenLoadAnimation ()
@property (nonatomic ,strong) UIImageView *loadingImageView;

@end
@implementation BZ_ComenLoadAnimation
-(id)init
{
    if (self = [super init])
    {
        self.frame = CGRectMake(0,0,screen_width,screen_height);
        self.backgroundColor = RGBA(0, 0, 0, .5);
        [self addSubview:self.loadingImageView];
        
        self.loadingImageView = [[UIImageView alloc]init];
        [self addSubview:self.loadingImageView];
        
        self.loadingImageView.frame = CGRectMake((screen_width-30)/2, (screen_height-30)/2, 34, 30);
        
//        NSMutableArray *imgsArr = [NSMutableArray array];
//        for(int i =0;i<17;i++){
//            NSString *imageStr= [NSString stringWithFormat:@"%i",i];
//            [imgsArr addObject:[UIImage imageNamed:imageStr]];
//        }
        NSArray * imgsArr = @[[UIImage imageNamed:@"eff_loading_01"],[UIImage imageNamed:@"eff_loading_02"],[UIImage imageNamed:@"eff_loading_03"],[UIImage imageNamed:@"eff_loading_04"],[UIImage imageNamed:@"eff_loading_05"],[UIImage imageNamed:@"eff_loading_06"],[UIImage imageNamed:@"eff_loading_07"],[UIImage imageNamed:@"eff_loading_08"],[UIImage imageNamed:@"eff_loading_09"],[UIImage imageNamed:@"eff_loading_10"],[UIImage imageNamed:@"eff_loading_11"],[UIImage imageNamed:@"eff_loading_12"],[UIImage imageNamed:@"eff_loading_13"],[UIImage imageNamed:@"eff_loading_14"]];
        // 设置动画图片数组
        [self.loadingImageView setAnimationImages:imgsArr];
        // 设置动画持续时间
        [self.loadingImageView setAnimationDuration:2];
        // 设置动画重复次数  (当值为0时，表示无限次)
        self.loadingImageView.animationRepeatCount = 0;
        
    }
    return self;
}

- (void)showLoadingView
{
    [UIView animateWithDuration:0.25 animations:^{
        
        [self.loadingImageView startAnimating];
    } completion:^(BOOL finished) {
        
    }];
}
- (void)removeView
{
    [UIView animateWithDuration:0.25 animations:^{
        [self.loadingImageView stopAnimating];
        [self removeFromSuperview];
    } completion:^(BOOL finished) {
    }];
    
    
    
}
@end
